﻿@page "/Page2"

@inject SwalService SwalInject
@inject IServiceProvider ServiceProvider
<h3>Page2</h3>

<SweetAlert></SweetAlert>

<Button OnClick="@InjectClick">注入的按钮</Button>

<Button OnClick="@ServiceProviderClick">ServiceProviderHelper的按钮</Button>

<Button OnClick="@InjectServiceProvider">使用注入ServiceProvider获取的Service，可以弹出，是否可以在哪里存储一下？</Button>

@code {


    private async Task InjectClick(MouseEventArgs obj)
    {
        await SwalInject.Show(new SwalOption()
        {
            Content = "注入的Content",
            IsConfirm = true
        });
    }

    private async Task ServiceProviderClick(MouseEventArgs obj)
    {
        var swalService = ServiceProviderHelper.ServiceProvider.GetService(typeof(SwalService)) as SwalService;
        await swalService.Show(new SwalOption()
        {
            Content = "ServiceProvider的Content",
            IsConfirm = true
        });
    }

    private async Task InjectServiceProvider()
    {
        var swalService = ServiceProvider.GetService(typeof(SwalService)) as SwalService;
        await swalService.Show(new SwalOption()
        {
            Content = "Inject的ServiceProvider的Content",
            IsConfirm = true
        });
    }

}